
//过滤侧边栏数据或者路由数据的方法
export const filterMenusOrRoutes = (arr:any,role:string)=>{
    //fliter 筛选侧边栏一级路由   
    //!item.role 返回没有roles的对象 || item.roles.includes(role) 返回包含本地存储角色的对象
        return arr.filter((item:any)=>!item.roles || item.roles.includes(role))
        .map((ele:any)=>{ //
            const newEle = {
                ...ele
            }
            if(ele.children){
               newEle.children = filterMenusOrRoutes(ele.children,role)
            }
            return newEle;
        })
}
 
